/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkg23designpatterns.za.ac.cput.behavioural.mediator;

/**
 *
 * @author Oceanwave
 */
public class DollarConverter 
{
    Mediator mediator;
    public static final double DOLLAR_UNIT = 1.0f;
    public static final double EURO_UNIT = 0.7f;
    public static final double KRONA_UNIT = 0.8f;

    public DollarConverter(Mediator mediator) {
        this.mediator = mediator;
        mediator.registerDollarConverter(this);
    }
    
    private double convertEurosToDollars(double euros)
    {
        double dollars = euros * (DOLLAR_UNIT/EURO_UNIT);
        System.out.println("Converting euros " + euros + " to " + dollars);
        return dollars;
    }
    
    private double convertKronarToDollars(double kronar)
    {
        double dollars = kronar * (DOLLAR_UNIT/KRONA_UNIT);
        System.out.println("Converting kronar " + kronar + " to " + dollars);
        return dollars;
    }
    
    public double convertCurrencyToDollars (double amount, String unitOfCurrency)
    {
        if ("krona".equalsIgnoreCase(unitOfCurrency))
            return convertKronarToDollars(amount);
        else
            return convertEurosToDollars (amount);
    }
    
}
